<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        console.log(maxr("mmmiijjjjkkkkkkssptr"));
        function maxr(char){
            var a = 0,b = 1;
            var maxchar = "";
            var maxlength = 0;
            while(a < char.length-2){
                if(char.charAt(a) === char.charAt(b)){
                    b++;
                }else{
                    if(b - a > maxlength){
                        maxlength = b - a;
                        maxchar = char.slice(a,b);
                    }
                    a = b;
                    b = a + 1;
                }
            }
            return maxchar;
        }
    </script>
</head>
<body>
    
</body>
</html>